package PTA.Mianxiangduixiang.ex08;

import java.util.*;

class Employee implements Comparable<Employee>{
   private int number;//职工编号
   private int tscore;//团体险业绩
   private int pscore;//个体险业绩
   private String name;//姓名
   private String sex;//性别
    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    public int getTscore() {
        return tscore;
    }

    public void setTscore(int tscore) {
        this.tscore = tscore;
    }

    public int getPscore() {
        return pscore;
    }

    public void setPscore(int pscore) {
        this.pscore = pscore;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }
Employee(){}
    Employee(int number,int tscore,int pscore,String name,String sex){
        this.number = number;
        this.tscore = tscore;
        this.pscore = pscore;
        this.name = name;
        this.sex = sex;
    }

    @Override
    public String toString() {
        return number +
                "," + tscore +
                "," + pscore +
                "," + name +
                "," + sex;
    }
    @Override
    public int compareTo(Employee s) {
        int ret=this.pscore+this.tscore-s.getPscore()-s.getTscore();
        if (ret>0) {
            ret = 1;
        }
        else if (ret<0)
        {
            ret=-1;
        }
        return ret;
    }
}

class newComparetor implements Comparator<Employee> {
    public newComparetor() {
    }

    @Override
    public int compare(Employee o1, Employee o2) {
        int ret=o1.getTscore()-o2.getTscore();
        if (ret>0){
            ret=1;
        }
        else if (ret<0)
        {
            ret=-1;
        }
        return ret;
    }
}


public class ex08 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        List<Employee> ss = new ArrayList<Employee>();
        ss.add(new Employee(1,500,400,"职工1","female"));
        ss.add(new Employee(3,600,300,"职工3","male"));
        ss.add(new Employee(2,400,600,"职工2","female"));
        ss.add(new Employee(4,800,200,"职工4","female"));
        ss.add(new Employee(5,500,700,"职工5","male"));
  Collections.sort(ss);
        System.out.println("编号,团险,个险,姓名,性别");
  for(Employee s:ss){
      System.out.println(ss.toString());
  }
  ss.sort(new newComparetor());
        System.out.println("编号,团险,个险,姓名,性别");
        for(Employee s:ss){
            System.out.println(s.toString());
        }
    }
}
